package com.hxzy.site.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.site.entity.TtSite;
import com.hxzy.site.mapper.TtSiteMapper;
import com.hxzy.site.service.TtSiteService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mingqian.Wu
 * @since 2023-06-26
 */
@Service
@DataSource(DataSourceType.SITE)
public class TtSiteServiceImpl extends ServiceImpl<TtSiteMapper, TtSite> implements TtSiteService {


    @Override
    public List<TtSite> searchSite(TtSite ttSite) {
        QueryWrapper<TtSite> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(Objects.nonNull(ttSite.getName()),"name",ttSite.getName());
        queryWrapper.eq(Objects.nonNull(ttSite.getProvince()),"province",ttSite.getProvince());
        queryWrapper.eq(Objects.nonNull(ttSite.getCity()),"city",ttSite.getCity());
        queryWrapper.eq(Objects.nonNull(ttSite.getCounty()),"county",ttSite.getCounty());
        queryWrapper.eq(Objects.nonNull(ttSite.getSiteType()),"site_type",ttSite.getSiteType());
        queryWrapper.eq(Objects.nonNull(ttSite.getBusinessAffiliationId()),"business_affiliation_id",ttSite.getBusinessAffiliationId());
        List<TtSite> ttSites = baseMapper.selectList(queryWrapper);
        return ttSites;
    }

    @Override
    public List<TtSite> getList() {
        List<TtSite> ttSites = baseMapper.selectList(null);
        return ttSites;
    }

    @Override
    public TtSite getSourceOne(String id) {
        TtSite ttSite = baseMapper.selectById(id);
        return ttSite;
    }
}
